import 'package:base_lib/common/widget/orgin/top_reminder.dart';
import 'package:base_lib/dictionary/dictionary_provider.dart';
import 'package:base_lib/index.dart';
import 'package:base_lib/app.dart';
import 'package:common_lib/common_compoent.dart';
import 'package:doctor_login_lib/component.dart';
import 'package:doctor_prescribe_lib/doctor_prescribe_component.dart';
import 'package:doctor_prescribe_lib/prescribe_util.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class DoctorPrescribeLib {
  static init() {
    App.initializer(
        [CommonComponent(), DoctorPrescribeComponent(), DoctorLoginComponent()],
        DoctorLoginComponent.loginPage,
        DoctorPrescribeComponent.offlineBasicInfoPage);
  }

  static initWithContext(BuildContext context) {
    ScreenAdapter.getInstance().init(context);
  }

  static showAddressPicker(BuildContext context) {
    AddressPicker.showAddressPicker(context: context, height: 300);
  }

  static doRegEvent(BuildContext context) {
    EventBus.instance.register("test", (context, parameters) {
      Utils.log('%' * 10);
      var info = parameters.getString('t');
      Utils.log(info);
      TopReminder.info(context, info);
      return null;
    });
  }

  static postTest(BuildContext context) {
    EventBus.instance.post(context, "test",
        Parameters()..putString("t", DateTime.now().toIso8601String()));
  }

  static GenderBean sel;

  showGenderPicker(BuildContext context) async {
    sel = await GenderPicker.showGenderPicker(
        context: context, height: 200, selectedItem: sel);
    Utils.log("${sel.name}--${sel.code}");
  }

  getSicknessGroup(BuildContext context) {
    DictionaryProvider.getSicknessGroup();
  }

  getSicknessInfo(BuildContext context) {
    DictionaryProvider.getSicknessItem();
  }

  showPrescribeDialog(BuildContext context) {
    PrescribeUtil.showPrescribeDialog(context);
  }

  jump2rpOrderPage(BuildContext context){
    Routers.navigateTo(context, DoctorPrescribeComponent.rpOrderPage);
  }

  jump2Login(BuildContext context){
    Routers.navigateTo(context, DoctorLoginComponent.loginPage);
  }
}

class TipWrapper extends StatelessWidget {
  final Widget child;

  TipWrapper(this.child);

  @override
  Widget build(BuildContext context) {
    return OverlaySupport(
      child: child,
    );
  }
}
